#ifndef QRESOURCETREEWIDGET_H
#define QRESOURCETREEWIDGET_H

#include "corelibglobal.h"

#include <QTreeWidget>
#include <QTreeWidgetItem>
#include <QMap>

class QListWidgetItem;

namespace CORELIB
{

    class QResourceListWidget;
    class QResourceDelegate;

    class CORELIB_EXPORT QResourceTreeWidget : public QTreeWidget
    {
        Q_OBJECT
    public:
        explicit QResourceTreeWidget(QWidget *parent = 0);

        void    getSelectResource(QString &firstName,QString &lastName);
    public slots:
        void    add(const QString& firstName,const QString &lastName);
    signals:

    protected slots:
        void    select(QListWidgetItem *item);
        void    doubleSelect(QListWidgetItem *item);
    protected:
        void    mousePressEvent(QMouseEvent *event);
        void    resizeEvent(QResizeEvent *event);

        void    calcSize();
    signals:
        void    selectChanged(const QString &firstName,const QString &lastName);
        void    doubleClick(const QString &firstName,const QString &lastName);
    protected:
        friend class QResourceDelegate;
    protected:
        QMap<QString,QTreeWidgetItem*>      m_items;
        QMap<QString,QResourceListWidget*>  m_widgets;
        QMap<QResourceListWidget*,QTreeWidgetItem*> m_widgetToItem;
        QIcon                               m_icon;
        QListWidgetItem*                    m_select;
    };

}

#endif // QRESOURCETREEWIDGET_H
